<form action="postnumre.php">
    <table border="1">
        <tr>
            <th>Postnummer</th><td><input type="text" name="postnummer" /></td>
       	</tr>
        <tr>
            <th>By</th><td><input type="text" name="by" /></td>
       	</tr>
        <tr>
            <td colspan="2"><input type="submit" value="Opret" /></td>
      	</tr>
	</table>
</form>
<a href="menu.html">Tilbage til menu</a>
<?php
	$connection = mysqli_connect("localhost","root","","frederik-adressedatabase");
	if(isset($_REQUEST["postnummer"])){
		$query = "INSERT INTO Postnummer VALUES($_REQUEST[postnummer],'$_REQUEST[by]')";
		$result = mysqli_query($connection,$query);
	}
?>
<table border="1">
	<tr>
    	<th>Postnummer</th>
        <th>By</th>
	</tr>
<?php
	$query = "SELECT * FROM Postnummer ORDER BY Postnummer";
	$result = mysqli_query($connection,$query);
	while($record = mysqli_fetch_array($result)){
		echo "<tr><td>$record[Postnummer]</td><td><a href='retpostnummer.php?postnummer=$record[Postnummer]'>$record[By]</a></td></tr>";
	}
?>
</table>